const text = document.querySelector('.name input')
const password = document.querySelector('.password input')
text.addEventListener('focus', function () {
    text.style.border = '1px solid #27ba9b'
})
text.addEventListener('blur', function () {
    text.style.border = '1px solid #cfcdcd'
})

password.addEventListener('focus', function () {
    password.style.border = '1px solid #27ba9b'
})
password.addEventListener('blur', function () {
    password.style.border = '1px solid #cfcdcd'
})


const user = document.querySelector('.user')
const btn = document.querySelector('.btn')
const option1 = document.querySelector('#option1')

function age(a) {
    user.classList.remove('userNone')
    user.classList.add('userBlock')
    user.children[1].innerHTML = a
    setTimeout(function () {
        user.classList.remove('userBlock')
        user.classList.add('userNone')
    }, 1500)
}
// <!-- 用户输入判断 弹出警告框-->
btn.addEventListener('click', function () {
    if (text.value === '') {
        age('用户名不能为空')
        return
    } else if (password.value === '') {
        age('密码不能为空')
        return
    } else if (!option1.checked) {
        age('请阅读并勾选用户协议')
        return
    } else if (text.value !== localStorage.getItem('names')) {
        age('用户名输入有误')
        return
    } else if (password.value !== localStorage.getItem('password')) {
        age('密码输入有误')
        return
    } else {
        location.href = '../index.html'
        localStorage.setItem('mima', '11')
        localStorage.setItem('goin', 'goin')
    }
})

const quit = localStorage.getItem('quit')
const i = document.querySelector('.user i')
if (quit) {
    new Dialog({
        text: '退出成功'
    })
    localStorage.removeItem('quit')
}
